import { Sequelize } from 'sequelize'
import config from './config.js';


const sequelize = new Sequelize({
  dialect: 'mysql',
  host: config.MYSQL_HOST,
  username: config.MYSQL_USER,
  password: config.MYSQL_PASSWORD,
  database: config.MYSQL_DB,
  port: config.MYSQL_PORT,
  logging: false,
  //时区设置
  timezone: "+08:00",
  pool: {
    max: 20, // 连接池最大连接数量
    min: 5, // 连接池最小连接数量
    acquire: 30000, // 连接超时时间（毫秒）
    idle: 10000
  }
})

// 测试连接
/*sequelize.authenticate().then(() => {
  console.log('数据库连接成功.')
}).catch((err) => {
  console.error('Unable to connect to the database:', err)
})*/

export default sequelize
